package com.example.administrator.myapplication.fragment;


import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.administrator.myapplication.R;
import com.example.administrator.myapplication.databinding.FragmentDownLoadBinding;
import com.example.administrator.myapplication.download.DownAlbumFragment;
import com.example.administrator.myapplication.download.DownLoadingFragment;
import com.example.administrator.myapplication.download.DownVoidFragment;
import com.example.administrator.myapplication.subscribe.SubCommentFragment;
import com.example.administrator.myapplication.subscribe.SubHistoryFragment;
import com.example.administrator.myapplication.subscribe.SubSubFragment;
import com.example.administrator.myapplication.until.CommentFragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class DownLoadFragment extends Fragment {
     private FragmentDownLoadBinding binding;
    private CommentFragmentPagerAdapter adapter;
    public DownLoadFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return DataBindingUtil.inflate(inflater,R.layout.fragment_down_load, container, false).getRoot();
    }
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        binding = DataBindingUtil.getBinding(view);
        aboutTablayout();
    }

    private void aboutTablayout() {
        String title[]  = new String[]{"专辑","声音","下载中"};
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(new DownAlbumFragment());
        fragments.add(new DownVoidFragment());
        fragments.add(new DownLoadingFragment());
        adapter = new CommentFragmentPagerAdapter(getChildFragmentManager(),title,fragments);
        binding.viewpager.setAdapter(adapter);
        binding.tablayout.setupWithViewPager(binding.viewpager);
    }

}
